﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HamcoWcs.Models.Monitors
{
    public class BCRMonitor
    {
        public BCRMonitor(string bcrName, int offset, int position, string remark)
        {
            BcrName = bcrName;
            Offset = offset;
            Position = position;
            Remark = remark;
        }

        public string BcrName { get; set; }
        public int Offset { get; set; }
        public int Position { get; set; }
        public string Remark { get; set; }
        public bool BypassState { get; set; }

        /// <summary>
        /// 写启用置1，写禁用写2，无指令写0
        /// </summary>
        public int Cmd { get; set; } = 0;


        public void Update(byte[] content)
        {
            var t = content.Skip(Offset).Take(1).First();
            BypassState = ((t >> Position) & 1) == 1;
        }

        
    }
}
